package com.kim.zull.server.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.exception.ZuulException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * @Project: kim-security-oauth
 * @PackageName: com.kim.zull.server.filter
 * @FileName: OauthUserInfoFilter.java
 * @Description: The OauthUserInfoFilter is...
 * @Author: kimwu
 * @Time: 2020-12-15 10:01:41
 */
@Component
@Slf4j
public class OauthUserInfoFilter extends ZuulFilter {

    /**
     * 过滤器类型
     * org.springframework.cloud.netflix.zuul.filters.support.FilterConstants 这个类
     * pre：在请求被路由（转发）之前调用
     * route：在路由（请求）转发时被调用
     * error：服务网关发生异常时被调用
     * post：在路由（转发）请求后调用
     *
     * @return
     */
    @Override
    public String filterType() {
        return FilterConstants.PRE_TYPE;
    }

    @Override
    public int filterOrder() {
        return -1;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() throws ZuulException {
        log.info("我是zuul的自定义过滤器[未实现功能]");
        return null;
    }
}
